package com.example.cloudgateway9527.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 啦啦啦
 * 自定义路由规则
 */
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customLocator(RouteLocatorBuilder builder){
        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("guonei",r->r.path("/guonei").uri("http://news.baidu.com/guonei")).build();
        routes.route("guoji",r->r.path("/guoji").uri("http://news.baidu.com/guoji")).build();
        return routes.build();
    }
}
